#include "wxscolourdialog.h"
#include "../wxsitemresdata.h"
#include <wx/colordlg.h>

namespace {
  wxsRegisterItem<wxsColourDialog> Reg( _T( "ColourDialog" ), _T( "ColourDialog" ), wxsTTool, _T( "对话框" ), 200, false );
}

wxsColourDialog::wxsColourDialog( wxsItemResData* Data ):
  wxsTool( Data, &Reg.Info ) {
  m_ChooseFull = true;
}

void wxsColourDialog::OnBuildCreatingCode() {
  switch( GetLanguage() ) {
    case wxsCPP: {
      AddHeader( _T( "<wx/colordlg.h>" ), GetInfo().ClassName, hfInPCH );
      bool Defaults = true;
      if( !m_ChooseFull ) {
        Defaults = false;
      }
      if( m_Colour.m_type != wxsCOLOUR_DEFAULT ) {
        Defaults = false;
      }
      if( !Defaults ) {
        wxString ColourDataName = GetCoderContext()->GetUniqueName( _T( "__ColourData" ) );
        Codef( _T( "wxColourData %v;\n" ), ColourDataName.wx_str() );
        if( !m_ChooseFull ) {
          Codef( _T( "%v.SetChooseFull(%b);\n" ), ColourDataName.wx_str(), m_ChooseFull );
        }
        if( m_Colour.m_type != wxsCOLOUR_DEFAULT ) {
          Codef( _T( "%v.SetColour(%l);\n" ), ColourDataName.wx_str(), &m_Colour );
        }
        Codef( _T( "%C(%W, &%v);\n" ), ColourDataName.wx_str() );
      } else
      { Codef( _T( "%C(%W);\n" ) ); }
      BuildSetupWindowCode();
      return;
    }
    case wxsUnknownLanguage:
    default: {
      wxsCodeMarks::Unknown( _T( "wxsColourDialog::OnBuildCreatingCode" ), GetLanguage() );
    }
  }
}

void wxsColourDialog::OnEnumToolProperties( M_Code_unused long Flags ) {
  WXS_BOOL( wxsColourDialog, m_ChooseFull, _T( "Full dialog" ), _T( "choosefull" ), true );
  WXS_COLOUR( wxsColourDialog, m_Colour, _T( "Colour" ), _T( "colour" ) );
}
